//
//  CHArrayExtensions.h
//  Chocolat
//
//  Created by Pieter Omvlee on 4/19/08.
//  Copyright 2008 Bohemian Coding. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface NSArray (CHArrayExtensions)

- (id)firstObject;
- (id)head;
- (NSArray *)tail;
- (id)end;
- (NSArray *)front;

- (NSArray *)reversedArray;

- (BOOL)containsObjectOfClass:(Class)aClass;
- (BOOL)containsObjectFromArray:(NSArray *)anArray;
- (BOOL)containsOnlyObjectsOfClass:(Class)aClass;
- (BOOL)containsSingleClass;
- (BOOL)containsEqualObjects;

- (NSArray *)arrayWithOnlyObjectsOfClass:(Class)aClass;

- (NSArray *)map:(SEL)sel;
- (NSArray *)map:(SEL)sel withObject:(id)obj;
- (NSArray *)map:(SEL)sel withObject:(id)obj1 withObject:(id)obj2;

- (id)deepCopy;
- (id)mutableDeepCopy;

- (void)performSelector:(SEL)sel withEachObjectAsArgumentToTarget:(id)target;

- (NSArray *)sortedArrayUsingKey:(NSString *)key;
- (NSArray *)sortedArrayUsingKeys:(NSArray *)keys;
- (NSArray *)arrayByRemovingObject:(id)anObject;

- (NSDictionary *)dictionaryBySplittingArrayUsingKey:(NSString *)aKey;

- (BOOL)isValidIndex:(int)anIndex;

@end

@interface NSMutableArray (NSMutableArrayAdditions)
- (void)addObjectIfNotNil:(id)obj;
- (void)removeFirstObject;
- (void)insertObjectsFromArray:(NSArray *)array atIndex:(int)index;
- (void)onlyKeepObjectsFromClass:(Class)aClass;
@end